package conlon.seata02.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import conlon.api.form.AccountForm;
import conlon.seata02.dao.AccountDao;
import conlon.seata02.entity.AccountEntity;
import conlon.seata02.service.AccountService;
import io.seata.spring.annotation.GlobalLock;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 用户信息 服务实现类
 * </p>
 *
 * @author conlon
 * @since 2021-08-16
 */
@Service
public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> implements AccountService {


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void createAccount(AccountForm form) {
        this.save(new AccountEntity().setId(form.getAccountId()).setAccountName(form.getAccountName()));
    }

    @Override
    @GlobalLock
    public AccountEntity getAccountById(Long accountId) {
        return baseMapper.getAccountById(accountId);
    }
}
